<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>SM4</title>
    <script src="../dist/bundle.js"></script>
</head>

<body>


    <script>
        var sm4Config = {
            // encrypt/decypt main key; cannot be omitted
            key: 'JeF8U9wHFOMfs2Y8',

            // optional; can be 'cbc' or 'ecb'
            mode: 'cbc', // default

            // optional; when use cbc mode, it's necessary
            iv: 'UISwD9fW6cFh9SNS', // default is null

            // optional: this is the cipher data's type; Can be 'base64' or 'text'
            cipherType: 'base64' // default is base64
        }

        var sm4 = new smCrypt(sm4Config)


        var plaintext = '中国国密加解密算法'
        var ciphertext = sm4.encrypt(plaintext)

        console.log(ciphertext);


        var plaintext = sm4.decrypt(ciphertext)


         console.log(ciphertext);
    </script>

</body>

</html>